﻿#region Header
// ------------------------ Licence / Copyright ------------------------
// 
// ScrumTable for Scrum Meeting Support
// Copyright © HSR - Hochschule für Technik Rapperswil
// All Rights Reserved
// 
// Author:
//  Michael Gfeller Silvan Gehrig Patrick Boos
// 
// ---------------------------------------------------------------------
#endregion

#region Usings

using System;
using System.Collections;
using System.Collections.Generic;
using ScrumTable.Common;

#endregion

namespace ScrumTable.BL.DM.DataManagement
{
    /// <summary>
    /// Represents the method that handles the DomainContextSyncError event.
    /// </summary>
    /// <param name="sender">Specifies the sender of the event. This may be the collection itself or the underlying context.</param>
    /// <param name="e">Arguments which contain information about the event.</param>
    public delegate void DomainSyncErrorHandler(object sender, DomainSyncErrorArgs e);

    /// <summary>
    /// Represents an event arguments class which contains additional
    /// information about an event if an error occurred during the underlying
    /// data sync procedure.
    /// </summary>
    public class DomainSyncErrorArgs : EventArgs
    {
        #region Declarations
        //--------------------------------------------------------------------
        // Declarations
        //--------------------------------------------------------------------

        #endregion

        #region Properties
        //--------------------------------------------------------------------
        // Properties
        //--------------------------------------------------------------------

        /// <summary>
        /// Gets the item which caused the error.
        /// </summary>
        public DomainBase ErrorItem { get; private set; }

        /// <summary>
        /// Returns true if the error could not be categorized.
        /// </summary>
        public bool IsUnkown { get { return (ErrorInfo.Count == 0); } }

        /// <summary>
        /// Gets a list of error information which contain additional details
        /// of the sync error.
        /// </summary>
        public IList<DomainSyncErrorInfo> ErrorInfo { get { return ErrorItem.SynchronizationErrors; } }

        #endregion

        #region Constructors / Destructor
        //--------------------------------------------------------------------
        // Constructors / Destructor
        //--------------------------------------------------------------------

        /// <summary>
        /// Creates a new DomainSyncErrorArgs instance. This constructor
        /// is protected internal because its needed by derived or package classes only.
        /// </summary>
        internal protected DomainSyncErrorArgs(DomainBase errorItem)
        {
            PreCondition.AssertNotNull(errorItem, "errorItem");

            ErrorItem = errorItem;
        }

        #endregion

        #region Methods
        //--------------------------------------------------------------------
        // Methods
        //--------------------------------------------------------------------

        #endregion

        #region Events
        //--------------------------------------------------------------------
        // Events
        //--------------------------------------------------------------------

        #endregion
    }
}